Net = {};
Net.version = 2;
Net.baseurl = "https://coff.sadld.cn";
Net.urlSet = {
    notifyList: {
        url: contextPath + "api/notify/getByType",
        type: 1
    },
    nav: {
        url: contextPath + "api/navigation/getMainBottomNav",
        type: 1
    },
    resourceList: {
        url: contextPath + "api/navigation/getNavTopClassify",
        type: 1
    },
    resourceView: {
        url: contextPath + "api/navigation/getNavTopClassifyModule",
        type: 1
    },
    chapterContent: {
        url: contextPath + "api/chapter/getByNumber",
        type: 1
    },
    loadChapterList: {
        url: contextPath + "api/chapter/getAllByParentId",
        type: 1
    },
    tagList: {
        url: contextPath + "api/dance/loadAllTags",
        type: 1
    },
    refreshBatch: {
        url: contextPath + "api/navigation/getResourceViewData",
        type: 1
    },
    getList: {
        url: contextPath + "api/navigation/getResourceViewData",
        type: 1
    },
    loadType: {
        url: contextPath + "api/dance/loadType",
        type: 1
    },
    loadTags: {
        url: contextPath + "api/dance/loadTags",
        type: 1
    },
    loadHostTags: {
        url: contextPath + "api/dance/loadHostTags",
        type: 1
    },
    loadHostData: {
        url: contextPath + "api/dance/loadHostData",
        type: 1
    },
    loadCategory: {
        url: contextPath + "api/dance/loadCategory",
        type: 1
    },
    loadData: {
        url: contextPath + "api/dance/loadData",
        type: 1
    },
    carouselList: {
        url: contextPath + "api/carousel/getByType",
        type: 2
    },
    loadQd: {
        url: contextPath + "api/dance/sys_qd",
        type: 2
    },
    similarList: {
        url: contextPath + "api/dance/youLike",
        type: 2
    },
    updatePassword: {
        url: contextPath + "api/dance/updatePassword",
        type: 2
    },
    login: {
        url: contextPath + "api/dance/login",
        type: 2
    },
    bindPhoneCode: {
        url: contextPath + "api/dance/bindPhoneCode",
        type: 2
    },
    collectState: {
        url: contextPath + "api/collect/collectState",
        type: 2
    },
    switchCollect: {
        url: contextPath + "api/collect/switchCollect",
        type: 2
    },
    collectData: {
        url: contextPath + "api/collect/getAllByUserId",
        type: 2
    },
    loadSysConfig: {
        url: contextPath + "api/dance/loadSysConfig",
        type: 2
    },
    playLog: {
        url: contextPath + "api/dance/playLog",
        type: 2
    },
    playList: {
        url: contextPath + "api/dance/playList",
        type: 2
    },
    orderList: {
        url: contextPath + "api/order/orderList",
        type: 2
    },
    getLevelByUserId: {
        url: contextPath + "api/order/getLevelByUserId",
        type: 2
    },
    createOrder: {
        url: contextPath + "api/order/create",
        type: 2
    },
    bindPhone: {
        url: contextPath + "api/dance/bindPhone",
        type: 2
    },
    loadUser: {
        url: contextPath + "api/user/getByDeviceId",
        type: 2
    },
    searchData: {
        url: contextPath + "api/dance/search",
        type: 2
    }
};
Net.navUrlMaping = {
    1: {
        navigationType: 1,
        url: "comics/main"
    },
    2: {
        navigationType: 2,
        url: "movie/main"
    },
    3: {
        navigationType: 3,
        url: "novel/main"
    },
    4: {
        navigationType: 4,
        url: "short_video/main"
    },
    5: {
        navigationType: 5,
        url: "user/main"
    }
};
Net.randomString = function(f) {
    f = f || 32;
    var d = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz"
        , b = d.length
        , g = "";
    for (var c = 0; c < f; c++) {
        g += d.charAt(Math.floor(Math.random() * b))
    }
    return g
}
;
Net.getStringFingerprint = function(b) {
    var e = 0;
    for (var c = 0; c < b.length; c++) {
        e = ((e << 5) - e) + b.charCodeAt(c);
        e &= e
    }
    var a = e.toString(16);
    var d = a.replace(/[^\da-f]/gi, "");
    return d
}
;
Net.ajax = function(e, f, l, h, c) {
    //e : Net.urlSet.chapterContent {
    //         url: contextPath + "api/chapter/getByNumber",
    //         type: 1
    //     },
    //f : {
    //     "navigationType": 1,
    //     "parentId": "13942",
    //     "number": 1,
    //     "url": "/api/chapter/getByNumber",
    //     "time": "202482317"
    // }
    //l : 回调函数
    var b = e.url;
    var a = "";
    if (b != Net.urlSet.loadUser.url) {
        var t = Net.cacheAtob("dance_mh_user");
        if (t != null) {
            a = JSON.parse(t).id
        }
    }
    if (Net.version == 1) {
        $.ajax({
            type: "POST",
            url: b,
            data: f,
            async: false,
            success: function(u) {
                if (u.code == 200) {
                    if (l) {
                        l(u)
                    }
                } else {
                    if (h) {
                        h(u)
                    } else {
                        HTML.errorMsg(u.describe)
                    }
                }
            },
            error: function(u) {
                HTML.errorMsg("网络异常，请检查网络!!!")
            }
        })
    } else {
        var m = Net.reqData(b, f, e.type);
        var n = new Date();
        var g = n.getFullYear();
        var p = n.getMonth() + 1;
        var j = n.getDate();
        var k = n.getHours();
        var d = Net.getStringFingerprint(m);
        var i = "" + g + p + j + k + "_" + d;
        var o = Net.baseurl;
        var q = "GET";
        var s = o + contextPath + "open_api/data_" + i + ".js";
        var r = {
            data: m
        };
        if (e.type == 2) {
            q = "POST";
            s = contextPath + "open_api/data";
            r = {
                data: m,
                key: Net.randomString(10) + btoa(Net.randomString(10) + new Date().getTime() + Math.ceil(Math.random() * 100))
            }
        }
        $.ajax({
            type: q,
            url: s,
            data: r,
            async: c == undefined ? true : c,
            success: function(u) {
                u = Net.respData(u);
                if (u.code == 200) {
                    if (l) {
                        l(u)
                    }
                } else {
                    if (h) {
                        h(u)
                    } else {
                        HTML.errorMsg(u.describe)
                    }
                }
            },
            error: function(u) {
                HTML.errorMsg("网络异常，请检查网络!!!")
            }
        })
    }
}
;
Net.reqData = function(a, n, k) {
    //a : url
    //n : 参数
    //k :  1 即 {
    //     url: contextPath + "api/chapter/getByNumber",
    //     type: 1
    //   }.type
    // contextPath : /ui/
    n.url = App.replaceAll(a, contextPath.substring(0, contextPath.length - 1), "");    //消除contextPath
    var d = new Date();
    if (k == 1) {
        var l = d.getFullYear();
        var j = d.getMonth() + 1;
        var m = d.getDate();
        var o = d.getHours();
        n.time = "" + l + j + m + o
    } else {
        n.time = d.getTime()    //1724319134525
    }
    var r = JSON.stringify(n);
    r = btoa(encodeURIComponent(r));    //先url-encode再base64
    var c = r.length;
    var g = Math.floor(c / 10);
    var q = [];
    var e = 0;
    for (var f = 0; f <= 10; f++) {
        var h = f * g;
        var b = k == 1 ? "A" : Net.randomString(1);
        var p = r.substring(e, h);
        q.push(p);
        q.push(b);
        e = h
    }
    q.push(r.substring(e));
    r = q.join("");
    return r
}
;
Net.respData = function(a) {
    var f = [];
    var e = a.length;
    e = e - 10;
    var g = Math.floor(e / 10);
    var h = 0;
    for (var c = 0; c < 10; c++) {
        var b = c * g + 1 + c;
        var d = a.substring(b, b + g);
        d = d.split("");
        d = d.reverse().join("");
        f.push(d);
        h = b + g
    }
    f.push(a.substring(h + 1).split("").reverse().join(""));
    f = f.join("");
    a = decodeURIComponent(atob(f));
    a = a.replace(/[\r\n\s+]/g, " ");
    a = JSON.parse(a);
    return a
}
;
Net.cacheBtoa = function(a, c) {
    var b = JSON.stringify(c);
    if (Net.version == 2) {
        b = btoa(encodeURIComponent(b));
        b = b.split("").reverse().join("")
    }
    sessionStorage.setItem(a + "_" + Net.version, b)
}
;
Net.cacheAtob = function(a) {
    var b = sessionStorage.getItem(a + "_" + Net.version);
    if (Net.version == 2) {
        if (b) {
            b = b.split("").reverse().join("");
            b = decodeURIComponent(atob(b));
            return b
        }
    } else {
        return b
    }
    return null
}
;
Net.removeCache = function(a) {
    sessionStorage.removeItem(a + "_" + Net.version)
}
;
Net.nav = function(b, d) {
    var c = Net.cacheAtob("dance_mh_nav");
    if (c != undefined && c != null) {
        var a = {
            code: 200,
            data: JSON.parse(c)
        };
        d(a);
        return
    }
    Net.ajax(Net.urlSet.nav, {
        userId: b
    }, function(e) {
        Net.cacheBtoa("dance_mh_nav", e.data);
        d(e)
    })
}
;
Net.resourceList = function(c, f) {
    var e = "dance_mh_resource_list_" + c;
    var d = Net.cacheAtob(e);
    if (d != undefined && d != null) {
        var a = {
            code: 200,
            data: JSON.parse(d)
        };
        f(a);
        return
    }
    var b = {
        navigationType: c
    };
    Net.ajax(Net.urlSet.resourceList, b, function(g) {
        Net.cacheBtoa(e, g.data);
        f(g)
    })
}
;
Net.carouselList = function(c, f) {
    var e = "dance_mh_carousel_" + c;
    var d = Net.cacheAtob(e);
    if (d != undefined && d != null) {
        var a = {
            code: 200,
            data: JSON.parse(d)
        };
        f(a);
        return
    }
    var b = {
        navigationType: c
    };
    Net.ajax(Net.urlSet.carouselList, b, function(g) {
        f(g)
    })
}
;
Net.resourceView = function(c, d, g) {
    var f = "dance_mh_resource_view_" + d + "_" + c;
    var e = Net.cacheAtob(f);
    if (e != undefined && e != null) {
        var a = {
            code: 200,
            data: JSON.parse(e)
        };
        g(a);
        return
    }
    var b = {
        topClassifyId: c,
        navigationType: d
    };
    Net.ajax(Net.urlSet.resourceView, b, function(h) {
        Net.cacheBtoa(f, h.data);
        g(h)
    })
}
;
Net.notifyList = function(c, f) {
    var e = "dance_mh_notice_" + c;
    var d = Net.cacheAtob(e);
    if (d != undefined && d != null) {
        var a = {
            code: 200,
            data: JSON.parse(d)
        };
        f(a);
        return
    }
    var b = {
        navigationType: c
    };
    Net.ajax(Net.urlSet.notifyList, b, function(g) {
        f(g)
    })
}
;
Net.similarList = function(c, a, d) {
    var b = {
        navigationType: c,
        dataId: a
    };
    Net.ajax(Net.urlSet.similarList, b, d)
}
;
Net.chapterContent = function(d, b, a, e) {
    //d: Net.navUrlMaping["1"].navigationType = 1
    //b: $("#page-id").val()
    //a: parseInt($("#page-chapter-index").val());
    //e: 回调函数
    var c = {
        navigationType: d,
        parentId: b,
        number: a
    };
    Net.ajax(Net.urlSet.chapterContent, c, e)
}
;
Net.loadChapterList = function(c, a, d) {
    var b = {
        navigationType: c,
        parentId: a
    };
    Net.ajax(Net.urlSet.loadChapterList, b, d)
}
;
Net.tagList = function(b, c) {
    var a = {
        navigationType: b
    };
    Net.ajax(Net.urlSet.tagList, a, c)
}
;
Net.searchData = function(b, d, c) {
    var a = {
        navigationType: b,
        title: d,
        pageIndex: 1,
        pageSize: 60
    };
    Net.ajax(Net.urlSet.searchData, a, c)
}
;
Net.refreshBatch = function(c, f, e, j, g, b, h, d, k, a) {
    b = b ? b : 1;
    h = h ? h : 9;
    var i = {
        tableName: k,
        loadModel: d,
        navigationType: c,
        id: f,
        categoryId: e,
        dataSourceMode: j,
        extend: g,
        pageIndex: b,
        pageSize: h
    };
    Net.ajax(Net.urlSet.refreshBatch, i, a)
}
;
Net.typeDataList = function(e, b, g, j, f, c, d, h, a) {
    d = d ? d : 1;
    h = h ? h : 30;
    var i = {
        navigationType: e,
        id: b,
        categoryId: g,
        dataSourceMode: j,
        pageIndex: d,
        pageSize: h,
        sort: f,
        tagId: c
    };
    Net.ajax(Net.urlSet.getList, i, a)
}
;
Net.loadUser = function(d, g, a) {
    if (d == undefined) {
        d = App.device()
    }
    if (g == undefined) {
        g = App.getQueryParam("code")
    }
    var j = App.getQueryParam("deviceId");
    if (j != null) {
        d = j
    }
    var f = Net.cacheAtob("dance_mh_user");
    if (f != undefined && f != null) {
        var i = {
            code: 200,
            data: JSON.parse(f)
        };
        a(i);
        return
    }
    var h = {
        deviceId: d
    };
    var c = App.getQueryParam("sId");
    var e = App.getQueryParam("fromId");
    var b = App.getQueryParam("isApp");
    if (c != undefined || c != "") {
        h.sId = c
    }
    if (e != undefined || e != "") {
        h.fromId = e
    }
    if (b != undefined || b != "") {
        h.isApp = b
    }
    if (g != undefined || g != "") {
        h.fromCode = g
    }
    h.os = App.os();
    h.browser = App.browser();
    Net.ajax(Net.urlSet.loadUser, h, function(k) {
        Net.cacheBtoa("dance_mh_user", k.data);
        a(k)
    })
}
;
Net.reloadUser = function(c) {
    var b = App.device();
    var a = {
        deviceId: b,
        isLogin: 0
    };
    Net.ajax(Net.urlSet.loadUser, a, function(d) {
        Net.cacheBtoa("dance_mh_user", d.data);
        c(d)
    })
}
;
Net.loadType = function(c, b, d) {
    var a = {
        navigationType: c,
        typeId: b
    };
    Net.ajax(Net.urlSet.loadType, a, d)
}
;
Net.loadTags = function(c, b, d) {
    var a = {
        navigationType: c,
        tagIds: b
    };
    Net.ajax(Net.urlSet.loadTags, a, d)
}
;
Net.collectState = function(d, c, a, e) {
    var b = {
        navigationType: d,
        userId: c,
        dataId: a
    };
    Net.ajax(Net.urlSet.collectState, b, e)
}
;
Net.switchCollect = function(d, c, a, e, f) {
    var b = {
        navigationType: d,
        userId: c,
        dataId: a,
        state: e
    };
    Net.ajax(Net.urlSet.switchCollect, b, f)
}
;
Net.collectData = function(e, d, a, b, f) {
    var c = {
        navigationType: e,
        userId: d,
        pageIndex: a,
        pageSize: b
    };
    Net.ajax(Net.urlSet.collectData, c, f)
}
;
Net.loadSysConfig = function(a) {
    Net.ajax(Net.urlSet.loadSysConfig, {}, a, undefined, false)
}
;
Net.playLog = function(b, a, d, c) {
    Net.ajax(Net.urlSet.playLog, {
        navigationType: b,
        userId: a,
        resourceId: d
    }, c)
}
;
Net.playList = function(b, a, c) {
    Net.ajax(Net.urlSet.playList, {
        navigationType: b,
        userId: a
    }, c)
}
;
Net.orderList = function(a, b) {
    Net.ajax(Net.urlSet.orderList, {
        userId: a
    }, b)
}
;
Net.getLevelByUserId = function(a, b) {
    Net.ajax(Net.urlSet.getLevelByUserId, {
        userId: a
    }, b)
}
;
Net.createOrder = function(b, c, e, f) {
    var d = App.os();
    var a = App.browser();
    Net.ajax(Net.urlSet.createOrder, {
        userId: b,
        levelId: c,
        channelId: e,
        os: d,
        browser: a
    }, f)
}
;
Net.bindPhone = function(b, a, c, d) {
    Net.ajax(Net.urlSet.bindPhone, {
        userId: b,
        phone: a,
        code: c
    }, d)
}
;
Net.bindPhoneCode = function(b, a, c) {
    Net.ajax(Net.urlSet.bindPhoneCode, {
        userId: b,
        phone: a
    }, c)
}
;
Net.loadHostData = function(c, e) {
    var b = "dance_mh_hostDatas_" + c;
    var d = Net.cacheAtob(b);
    if (d != undefined && d != null) {
        var a = {
            code: 200,
            data: JSON.parse(d)
        };
        e(a);
        return
    }
    Net.ajax(Net.urlSet.loadHostData, {
        navigationType: c
    }, function(f) {
        e(f)
    })
}
;
Net.loadHostTags = function(c, e) {
    var b = "dance_mh_hostTags_" + c;
    var d = Net.cacheAtob(b);
    if (d != undefined && d != null) {
        var a = {
            code: 200,
            data: JSON.parse(d)
        };
        e(a);
        return
    }
    Net.ajax(Net.urlSet.loadHostTags, {
        navigationType: c
    }, function(f) {
        Net.cacheBtoa(b, f.data);
        e(f)
    })
}
;
Net.login = function(c, a, b, d) {
    Net.ajax(Net.urlSet.login, {
        account: c,
        password: a,
        deviceId: b
    }, function(e) {
        d(e)
    })
}
;
Net.updatePassword = function(b, a, c) {
    Net.ajax(Net.urlSet.updatePassword, {
        userId: b,
        password: a
    }, function(d) {
        c(d)
    })
}
;
Net.loadCategory = function(a, b) {
    Net.ajax(Net.urlSet.loadCategory, {
        navigationType: a
    }, function(c) {
        b(c)
    })
}
;
Net.loadData = function(a, b) {
    Net.ajax(Net.urlSet.loadData, a, function(c) {
        b(c)
    })
}
;
Net.loadQd = function(b, a, c) {
    Net.ajax(Net.urlSet.loadQd, {
        navigationType: b,
        type: a
    }, function(d) {
        c(d)
    })
}
;
Net.loadImage = function(b, a) {
    $.ajax({
        type: "GET",
        url: b,
        success: function(c) {
            a(c)
        },
        error: function(c) {}
    })
}
;
